package com.itdachang.devops.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
public class HelloController {

    @GetMapping("/hello")
    public String hello(){
        return "Hello Java DevOps!!!";
    }


    public static void main1(String[] args) {
//        Scanner sc = new Scanner(System.in);
//        String contentStr=sc.next();
//        String[] content = contentStr.split("");
        List<String> list = new ArrayList<String>(Arrays.asList("a","b","c"));
       // ArrayList<Object> objects = new ArrayList<>();
       // System.out.println(objects);
    //    objects.add("sss");



        list.remove(0);
        System.out.println(list);
      //  objects.remove(0);
//        contentList.add(2,"ssss");
//
////        System.out.println(contentList);
////        System.out.println(content);
   }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String contentStr=sc.next();
        String searchStr=sc.next();
        String[] content = contentStr.split("");
        List<String> contentList = new ArrayList<String>(Arrays.asList(content));
        ArrayList<Object> indexArray = new ArrayList<>();
        String[] search = searchStr.split("");
        int searchIndex=0;
        Boolean find=false;
        int totalCount=0;
        Boolean circle=true;
        while(circle){
            if(xunhuan(contentStr,searchStr,indexArray)){
                for (int i = 0; i < indexArray.size(); i++) {
                    contentList.remove(indexArray.get(i));
                }
                totalCount++;
            }
            contentStr="";
            for (int i = 0; i <contentList.size() ; i++) {
                contentStr+=contentList.get(i);
            }
            circle= xunhuan(contentStr, searchStr, indexArray);
        }
        System.out.println(totalCount);
    }

    private static Boolean xunhuan(String contentStr,String searchStr,ArrayList<Object> indexArray){
        String[] search = searchStr.split("");
        int searchIndex=0;
        Boolean find=false;
        for (int i = 0; i <search.length ; i++) {
            if(contentStr.indexOf(search[i])!=-1 && contentStr.indexOf(search[i])>=searchIndex){
                searchIndex= contentStr.indexOf(search[i]);
                indexArray.add(searchIndex);
                find=true;
            }else{
                find=false;
            }
        }

        return find;
    }

}
